package com.buaa.controller;

import com.buaa.common.Result;
import com.buaa.service.impl.UserActivityServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/userlog")
public class UserActivityController {

    @Autowired
    UserActivityServiceImpl userActivityServiceImpl;

    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable("id") Integer id, HttpServletRequest request){
        return userActivityServiceImpl.deleteByUserId(id, request);
    }

    @GetMapping("/page")
    public Map<String,Object> findPage(@RequestParam String policeId, @RequestParam String userName, @RequestParam Integer pageNum, @RequestParam Integer pageSize){
        pageNum = (pageNum-1) * pageSize;
        return userActivityServiceImpl.findPage(policeId, userName, pageNum, pageSize);
    }
}
